﻿using System.Reflection;
using 特性.Attr;
using 特性.Model;

namespace 特性.Extend
{
    public static class Extend
    {
        public static string GetDescription(this Enum obj)
        {
            FieldInfo filed = obj.GetType().GetField(obj.ToString());
            string result = "";
            if (filed.IsDefined(typeof(Remark), true))
            {
                var attribute = filed.GetCustomAttribute<Remark>();
                result = attribute.GetDescription();
            }
            return result;
        }
    }
}